Connectivity Software User's Guide and Reference
Examples - OPC UA Specialized - Kepware KEPServerEX - Read multiple

.NET

// This KEPServerEX/UA example shows how to read data (value, timestamps, and status code) of 3 attributes at once. In this
// example, we are reading a Value attribute of 3 different nodes, but the method can also be used to read multiple
// attributes of the same node.
//
// Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://forum.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.AddressSpace;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples.Specialized
{
    partial class Kepware_KEPServerEX_UA
    {
        public static void ReadMultiple()
        {
            UAEndpointDescriptor endpointDescriptor = "opc.tcp://localhost:49320";  // default KEPServerEX/UA endpoint 

            // Instantiate the client object.
            var client = new EasyUAClient();

            // Obtain attribute data. By default, the Value attributes of the nodes will be read.
            UAAttributeDataResult[] attributeDataResultArray = client.ReadMultiple(new[]
                {
                    // The UANodeId.KEPServerEX(...) helper method simplifies creation of node IDs for KEPServerEX/UA nodes.
                    new UAReadArguments(endpointDescriptor, UANodeId.KEPServerEX("Simulation Examples.Functions.Random1")),
                    new UAReadArguments(endpointDescriptor, UANodeId.KEPServerEX("Simulation Examples.Functions.Ramp1")),
                    new UAReadArguments(endpointDescriptor, UANodeId.KEPServerEX("Simulation Examples.Functions.Sine1")),
                    new UAReadArguments(endpointDescriptor, UANodeId.KEPServerEX("Simulation Examples.Functions.User1"))
                });

            // Display results.
            foreach (UAAttributeDataResult attributeDataResult in attributeDataResultArray)
            {
                if (attributeDataResult.Succeeded)
                    Console.WriteLine($"AttributeData: {attributeDataResult.AttributeData}");
                else
                    Console.WriteLine($"*** Failure: {attributeDataResult.ErrorMessageBrief}");
            }
        }
    }
}